home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr47 / funket.zip / DOTEXT.PRG < prev   
Text File  |  1995-01-26  |  6KB  |  232 lines

  1. * dotext.prg to try to set up funckyII ET text editing sys
  2.  
  3. #define NUM 3
  4. #include io.hdr
  5. #include system.hdr
  6. #include iif.hdr
  7. #include data.hdr
  8.  
  9. VarDef
  10.     long        TEXTEDIT[3]
  11.     CHAR(30)    sometext := "This is an entry            "
  12.     char(30)    moretext := "This is More Text!          "
  13.     char(12)    anumber  := "0.00"
  14. EndDef
  15.  
  16. FUNCTION LONG _etCreate PROTOTYPE
  17.    PARAMETERS Value Int aRow, Value Int aCol, const char abuffer,;
  18.                 Value Int attrib, value int asize,const char apicture
  19.  
  20. PROCEDURE _etDisplay PROTOTYPE
  21.     PARAMETERS value long textedit[&NUM]
  22.  
  23. PROCEDURE DOEDIT PROTOTYPE    // Actual keyboard handler you write
  24.     parameters  value int numvars
  25.        //  value long textedit[2],
  26.  
  27. FUNCTION INT _etScrRow PROTOTYPE
  28.     PARAMETERS value long textedit[&NUM]
  29.  
  30. FUNCTION INT _etScrCol PROTOTYPE
  31.     PARAMETERS value long textedit[&NUM]
  32.  
  33. PROCEDURE _csrput PROTOTYPE
  34.     PARAMETERS value int arow, value int acol
  35.  
  36. PROCEDURE _etInsert PROTOTYPE
  37.     PARAMETERS value long textedit[&NUM],value int nKey
  38.  
  39. PROCEDURE _etOverWrite PROTOTYPE
  40.     PARAMETERS value long textedit[&NUM],value int nKey
  41.  
  42. PROCEDURE _etBackSpace PROTOTYPE
  43.     PARAMETERS value long textedit[&NUM]
  44.  
  45. PROCEDURE _etCsrLeft PROTOTYPE
  46.     PARAMETERS value long textedit[&NUM],value int acount
  47.  
  48. PROCEDURE _etCsrRight PROTOTYPE
  49.     PARAMETERS value long textedit[&NUM],value int acount
  50.  
  51. PROCEDURE _etDelete PROTOTYPE
  52.     PARAMETERS value long textedit[&NUM]
  53.  
  54. PROCEDURE _etCsrEnd PROTOTYPE
  55.     PARAMETERS value long textedit[&NUM]
  56.  
  57. PROCEDURE _etCsrHome PROTOTYPE
  58.     PARAMETERS value long textedit[&NUM]
  59.  
  60. PROCEDURE _etfree PROTOTYPE
  61.     PARAMETERS value long textedit[&NUM]
  62.  
  63. PROCEDURE _etRetrieve PROTOTYPE
  64.     PARAMETERS value long textedit[&NUM],value int amode,const char abuffer
  65.  
  66. PROCEDURE _etSetFocus PROTOTYPE
  67.     PARAMETERS value long textedit[&NUM],value int aflag
  68.  
  69. PROCEDURE _csrtype PROTOTYPE
  70.     PARAMETERS value int csrsize
  71.     // 0 = bottom 2 scan lines, 1 - half-cursor
  72.     
  73. PROCEDURE _etActiveColor PROTOTYPE
  74.     PARAMETERS Value long textedit[&NUM], value int colorattr
  75.     
  76. PROCEDURE _etClear PROTOTYPE
  77.     PARAMETERS value long textedit[&NUM]
  78.  
  79. procedure force_main
  80.     
  81.     __color_std := 31
  82.     clear
  83.  
  84.     TEXTEDIT[0] := _etCreate(10, 27, sometext,113, 28, "@!")
  85.  
  86.     TEXTEDIT[1] := _etCreate(11, 27, moretext,113, 28, "@!")
  87.  
  88.     TEXTEDIT[2] := _etCreate(12, 34, anumber, 113, 12, "@$@F11.2@,,")
  89.     
  90.     @ 10,0 ?? "Hey How About This Stuff: "
  91.     @ 11,0 ?? "How about Them # Twos   : "
  92.     @ 12,0 ?? "Let's enter Adding Machine Style: "
  93.     
  94.     _etActiveColor(TEXTEDIT[0],94)
  95.     _etActiveColor(TEXTEDIT[1],79) 
  96.     _etActiveColor(TEXTEDIT[2],116)
  97.     
  98.     DOEDIT(3)
  99.     
  100.     _etRetrieve(TEXTEDIT[0],0,sometext)
  101.     _etRetrieve(TEXTEDIT[1],0,moretext)
  102.     _etRetrieve(TEXTEDIT[2],0,anumber)
  103.     
  104.     @ 14,0 ?? sometext
  105.     @ 15,0 ?? moretext
  106.     @ 16,0 ?? anumber
  107.     
  108.     _etfree(TEXTEDIT[])
  109.     
  110.     @ 18,0 ?? "That's All Folks!"
  111. endpro
  112.  
  113. PROCEDURE DOEDIT
  114.     parameters value int numvars
  115.        //    value long textedit[2], (since public can reference directly)
  116. VarDef
  117.     int     nkey
  118.     logical insertmode
  119.     int        aindex
  120.     int     acount
  121.     int        x
  122.     logical firstchar
  123. EndDef
  124.  
  125. insertmode := insert_key()
  126. if insertmode
  127.     _csrtype(1)
  128. else
  129.     _csrtype(0)
  130. endif
  131.  
  132. firstchar := .t.
  133. nkey := 0
  134. aindex := 0
  135. acount := numvars - 1
  136. x := 0
  137. do while x <= acount
  138.     _etDisplay(TEXTEDIT[x])
  139. x++
  140. enddo
  141.  
  142. _etSetFocus(TEXTEDIT[aindex], 1)
  143.  
  144. do while .t.
  145.     _etDisplay(TEXTEDIT[aindex])
  146.     _csrput(_etscrrow(TEXTEDIT[aindex]),_etscrcol(TEXTEDIT[aindex]))
  147.     nKey := get_key()
  148.  
  149.     do case
  150.         case nKey >= 32 .and. nKey <= 255
  151.             if firstchar = .t.
  152.                 _etclear(TEXTEDIT[aindex])
  153.                 firstchar := .f.
  154.             endif
  155.             if insert_key()
  156.                 _etInsert(TEXTEDIT[aindex],nKey)
  157.             ELSE
  158.                 _etOverWrite(TEXTEDIT[aindex], nKey)
  159.             endif
  160.         case nKey = 27
  161.             exit
  162.         case nKey = 32850 // Insert Key
  163.             insertmode := insert_key()
  164.             if insertmode
  165.                 _csrtype(1)
  166.             else
  167.                 _csrtype(0)
  168.             endif
  169.         case nKey = 8      //  BS
  170.             IF firstchar = .t.
  171.                 firstchar := .f.
  172.             endif
  173.            _etBackSpace(TEXTEDIT[aindex])
  174.         case nKey = 32845     // right
  175.             if firstchar = .t.
  176.                 firstchar := .f.
  177.             endif
  178.            _etCsrRight(TEXTEDIT[aindex],1)
  179.         case nKey = 32843  // left
  180.             if firstchar = .t.
  181.                 firstchar := .f.
  182.             endif
  183.            _etCsrLeft(TEXTEDIT[aindex],1)
  184.         case nKey = 9 // tab
  185.             _etCsrRight(TEXTEDIT[aindex],5)
  186.         case nKey = 32783    // Shift-Tab
  187.             _etCsrLeft(TEXTEDIT[aindex],5) 
  188.         case nKey = 32851      // delete
  189.             _etDelete(TEXTEDIT[aindex])
  190.         case nKey = 32839     // home
  191.             if firstchar = .t.
  192.                 firstchar := .f.
  193.             endif
  194.             _etCsrHome(TEXTEDIT[aindex])
  195.         case nKey = 32847     // end
  196.             _etCsrEnd(TEXTEDIT[aindex])
  197.         case nKey = 32887    // ctrl-home
  198.              _etSetFocus(TEXTEDIT[aindex],0)
  199.              _etDisplay(TEXTEDIT[aindex])
  200.              aindex := 0
  201.              _etSetFocus(TEXTEDIT[aindex],1)
  202.         case nKey = 32885    // ctrl-end
  203.              _etSetFocus(TEXTEDIT[aindex],0)
  204.              _etDisplay(TEXTEDIT[aindex])
  205.              aindex := acount
  206.              _etSetFocus(TEXTEDIT[aindex],1)
  207.         case nKey = 32840 // UP
  208.             _etSetFocus(TEXTEDIT[aindex],0)
  209.             _etDisplay(TEXTEDIT[aindex])
  210.             IF aindex = 0
  211.                 exit
  212.             endif
  213.             aindex := aindex - iifN(aindex = 0,0,1)
  214.             firstchar := .t.
  215.             _etSetFocus(TEXTEDIT[aindex],1)
  216.         case nKey = 32848 .OR. nKey = 13         //down or ENTER
  217.             _etSetFocus(TEXTEDIT[aindex], 0)
  218.             _etDisplay(TEXTEDIT[aindex])
  219.             if aindex = acount
  220.                 exit
  221.             endif
  222.             aindex = aindex + iifN( aindex = acount, 0, 1 )
  223.             firstchar := .t.
  224.             _etSetFocus(TEXTEDIT[aindex], 1)
  225.         case nKey = 10 .or. nKey = 23   // ctrl-enter or ctrl-W
  226.             exit
  227.     endcase
  228.  
  229. enddo
  230.  
  231. endpro
  232.